{extend name="homeheader:header"/}
{block name="content"}
	<link rel="stylesheet" type="text/css" href="/home/css/class_dete.css" />
	<body style="overflow-x: hidden;">
		<div class="class_dete">
			<div class="top">
				<a href="javascript:history.back(-1)" class="back">
					<i class="iconfont">&#xe615;</i></a>
				{$catename.name}
			</div>
			<div class="butt row">
				<div class="col-xs-6">
					<a href="#" class="active">热门商品</a>
				</div>
				<div class="col-xs-6">
					<a href="#">价格</a>
				</div>
			</div>
			<div class="class_wrap">
				<input type="hidden" value="{$catename.id}" class="cateid">
				<ul class="goodsindex">
					
				</ul>
			</div>
		</div>
	</body>
</html>
<script type="text/javascript">
	var cid = $('.cateid').val();

	/* 商品列表 */
	$.post('/home/goods/goodsIndex',{id:cid},function(res){
		var data = res.data;
		console.log(data);
		var str = '';
		for(var i=0;i<data.length;i++){
			var obj = new Function("return" + data[i].g_pic)();
			var imgUrl = obj.photos[0].url;
			str += '<li>'
						+'<a href="{:url("/home/goods/goodsDetail/id/'+data[i].id+'")}">'
							+'<div class="list">'
							+'<div class="img">'
								+'<img src='+imgUrl+' />'
							+'</div>'
							+'<p>'+data[i].g_name+'</p>'
							+'<div class="mon">'
								+'￥'+data[i].g_cprice+'<del>￥'+data[i].g_oprice+'</del>'
							+'</div>'
						+'</div>'
						+'</a>'
					+'</li>';
		}

		$('.goodsindex').html(str);
	},'json');
</script>
{/block}